﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.holeschak.de/BmwDeepObd"
    elementFormDefault="qualified"
    xmlns="http://www.holeschak.de/BmwDeepObd"
    xmlns:mstns="http://www.holeschak.de/BmwDeepObd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

  <xs:simpleType name="string1-type">
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="include-type">
    <xs:annotation>
      <xs:documentation>
        Allows to include page fragments from another file.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="filename" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          File name of xml page fragment to include.
          File name could be absolute or relative.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:simpleType name="manufacturer-type">
    <xs:restriction base="xs:string">
      <xs:enumeration value="BMW">
        <xs:annotation>
          <xs:documentation>
            Manufacturer BMW
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Audi">
        <xs:annotation>
          <xs:documentation>
            Manufacturer Audi
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Seat">
        <xs:annotation>
          <xs:documentation>
            Manufacturer Seat
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="Skoda">
        <xs:annotation>
          <xs:documentation>
            Manufacturer Skoda
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="VW">
        <xs:annotation>
          <xs:documentation>
            Manufacturer VW
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="interface-type">
    <xs:restriction base="xs:string">
      <xs:enumeration value="BLUETOOTH">
        <xs:annotation>
          <xs:documentation>
            Bluetooth interface
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="ENET">
        <xs:annotation>
          <xs:documentation>
            Ethernet interface, not allowed for VW
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="ELMWIFI">
        <xs:annotation>
          <xs:documentation>
            ELM 327 WIFI device, not allowed for VW
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="FTDI">
        <xs:annotation>
          <xs:documentation>
            FTDI USB device, not allowed for VW
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="global-type">
    <xs:annotation>
      <xs:documentation>Global specifications for all pages.</xs:documentation>
    </xs:annotation>
    <xs:attribute name="ecu_path" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Relative or absolute path of the ecu files to use. If ommited the standard ecu path will be used (recommended).
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="log_path" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Relative or absolute path for the trace and data log files.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="append_log" type="xs:boolean" default="false" use="optional">
      <xs:annotation>
        <xs:documentation>
          If true the log file is appended.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="manufacturer" type="manufacturer-type" default="BMW" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the selected manufacturer
          If ommited BMW is the default.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="interface" type="interface-type" default="BLUETOOTH" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the selected communication interface.
          If ommited bluetooth is the default.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
      <xs:attribute name="search_abort_index" type="xs:int" default="-1" use="optional">
          <xs:annotation>
              <xs:documentation>
                  Index of the last search abort (VAG only). A values of -1 specifies no abort.
                  If ommited -1 is the default.
              </xs:documentation>
          </xs:annotation>
      </xs:attribute>
  </xs:complexType>

  <xs:complexType name="display-type">
    <xs:annotation>
      <xs:documentation>Specifies a result output row.</xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the output list entry.
          Must be a reference to a string.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="result" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the EDIABAS result.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="format" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          Format of the output value.
          The format specifier must have an EDIABAS apiResultText format.
          If ommited the function FormatResult() will be called.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="log_tag" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Tag for the data log file.
          Data is only logged if tag is present.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="string-type" mixed="true">
    <xs:annotation>
      <xs:documentation>String translation element.</xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the translation entry.
          It will be used as reference in page and display elements.
          Additionally it could be used with the GetPageString() function.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="strings-type">
    <xs:annotation>
      <xs:documentation>
        Group of translation strings for specific language.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="string" type="string-type" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="lang" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the language (culture).
          This could be either the short form e.g. 'de' or the long one 'de-DE'.
          If omitted this is the default languge if no other language tag matches.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="job-type">
    <xs:annotation>
      <xs:documentation>
        Specifies the EDIABAS job to execute.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="display" type="display-type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Id for job result identification.
          If this element is specified the result name will be: [id]#[data set index]#[result],
          otherwise: [name]#[result].
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="name" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the EDIABAS job to execute.
          If this element is used the function ExecuteJob() will not be called.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="args_first" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          A list of semicolon separated arguments for the first EDIABAS job call.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="args" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          A list of semicolon separated arguments for the EDIABAS job.
          For the first call args_first will be used if present.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="results" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          A list of semicolon separated results for the EDIABAS job.
          If omitted all results will be generated.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="jobs-type">
    <xs:annotation>
      <xs:documentation>
        Specifies all EDIABAS jobs to execute.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="job" type="job-type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="sgbd" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the SGBD file to load.
          If omitted the SGBD must be loaded in ExecuteJob().
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="mwtab" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Relative path of the used MwTab file. Only used for VAG configuration generator.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="mwdata" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          MwTab data from ECU. Only used for VAG configuration generator.
          The format is : [block],[index],[type],[unit base 64 encoded];[block],[index] ...
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="ecu-type">
    <xs:annotation>
      <xs:documentation>
        Specifies ECU to read the error memory from.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the ECU.
          Must be a reference to a string element.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sgbd" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the SGBD file to load.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="results" type="xs:string" use="optional" default="F_UW_KM">
      <xs:annotation>
        <xs:documentation>
          A list of semicolon separated results for the FS_LESEN_DETAIL job.
          If omitted only F_UW_KM result will be generated.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="read-errors-type">
    <xs:annotation>
      <xs:documentation>
        Groups nodes for error memory reading
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="ecu" type="ecu-type" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="code-type" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <![CDATA[
        This block can contain C# user code that will be compiled after reading the xml.
        The class for the code must be always named PageClass.
        It can contain the following pre-defined functions:
        public void CreateLayout(ActivityMain activity, JobReader.PageInfo pageInfo, LinearLayout pageLayout);
        public void DestroyLayout(JobReader.PageInfo pageInfo);
        public void UpdateLayout(JobReader.PageInfo pageInfo, bool pageValid, bool threadActive);
        public void ExecuteJob(EdiabasNet ediabas, ref Dictionary<string, EdiabasNet.ResultData=""> resultDict, bool firstCall);
        public void ExecuteJob(EdiabasNet ediabas, ref MultiMap<string, EdiabasNet.ResultData=""> resultDict, bool firstCall);
        public string FormatResult(JobReader.PageInfo pageInfo, Dictionary<string, EdiabasNet.ResultData> resultDict, string resultName);
        public string FormatResult(JobReader.PageInfo pageInfo, Dictionary<string, EdiabasNet.ResultData> resultDict, string resultName, ref Android.Graphics.Color? textColor);
        public string FormatResult(JobReader.PageInfo pageInfo, MultiMap<string, EdiabasNet.ResultData> resultDict, string resultName, ref Android.Graphics.Color? textColor);
        public void UpdateResultList(JobReader.PageInfo pageInfo, Dictionary<string, EdiabasNet.ResultData> resultDict, List<TableResultItem> resultList);
        public void UpdateResultList(JobReader.PageInfo pageInfo, MultiMap<string, EdiabasNet.ResultData> resultDict, List<TableResultItem> resultList);
        ]]>
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="show_warnigs" type="xs:boolean" default="false" use="optional">
      <xs:annotation>
        <xs:documentation>
          Show warnings during compilation of user code.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="page-type">
    <xs:annotation>
      <xs:documentation>
        Definition of one page.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="display" type="display-type" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="strings" type="strings-type" maxOccurs="unbounded"/>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="jobs" type="jobs-type" minOccurs="0" maxOccurs="1"/>
        <xs:element name="read_errors" type="read-errors-type" minOccurs="1" maxOccurs="1"/>
      </xs:choice>
      <xs:element name="code" type="code-type" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name" type="string1-type" use="required">
      <xs:annotation>
        <xs:documentation>
          Name of the page.
          Must be a reference to a string element.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="weight" type="xs:float" use="optional">
      <xs:annotation>
        <xs:documentation>
          Weight to control with width of the result colum.
          A value of 1 indicates 50% of the page width.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="logfile" type="string1-type" use="optional">
      <xs:annotation>
        <xs:documentation>
          Name of the data logfile. The symbol {D} will be replaced by the current date and time.
          Data logging is only available if a log file name has been set.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="activate" type="xs:boolean" default="false" use="optional">
      <xs:annotation>
        <xs:documentation>
          Specifies if an activation button will be displayed on the page.
          Use this to prevent automatic job execution on page change.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="pages-type">
    <xs:annotation>
      <xs:documentation>
        Group of all pages to display.
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="page" type="page-type"/>
        <xs:element name="include" type="include-type"/>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="configuration">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="global" type="global-type"/>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="pages" type="pages-type"/>
          <xs:element name="include" type="include-type"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="fragment">
    <xs:annotation>
      <xs:documentation>
        Fragment for include elements.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:choice>
        <xs:element name="page" type="page-type" maxOccurs="unbounded">
          <xs:annotation>
            <xs:documentation>
              Description of one page.
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="pages" type="pages-type">
          <xs:annotation>
            <xs:documentation>
              Description of all pages.
            </xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
